{include file='pub/header'/}
<title>部门</title>
</head>
<body>
<nav class="breadcrumb">{$breadNav} <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                       href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a class="btn btn-primary radius" onclick="category_add('添加分类','{:url(\'departmentAdd\')}')"
               href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加部门</a>
        </span>
    </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-bg table-hover table-sort">
            <thead>
            <tr class="text-c">
                <th width="80">ID</th>
                <th width="100">部门名称</th>
                <th width="150">创建时间</th>
                <th width="150">维护时间</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>
            {foreach $cateList as $list}
            <tr class="text-c">
                <td>{$list.id}</td>
                <td>{$list.name}</td>
                <td>{$list.create_time}</td>
                <td>{$list.update_time}</td>
                <td class="td-manage">
                    <a style="text-decoration:none" class="ml-5"
                       onClick="category_edit('部门编辑','{:url(\'departmentEdit\', [\'department_id\'=>$list.id])}')"
                       href="javascript:;" title="部门编辑"><i class="Hui-iconfont">&#xe6df;</i>部门编辑</a>
                    <a style="text-decoration:none" class="ml-5"
                       onClick="category_child('{$list.name}','{:url(\'department\', [\'department_id\'=>$list.id])}')"
                       href="javascript:;" title="查看"><i class="Hui-iconfont">&#xe681;</i>查看下级部门</a>
                    <a style="text-decoration:none" class="ml-5" onClick="category_del(this,'{$list.id}')"
                       href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i>删除</a>
                </td>
            </tr>
            {/foreach}
            </tbody>
        </table>
    </div>
</div>

{include file="pub/footer"/}
<script type="text/javascript">
    // $('.table-sort').dataTable({
    //     "aaSorting": [[1, "asc"]],//默认第几个排序
    //     "bStateSave": true,//状态保存
    //     "aoColumnDefs": [
    //         //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
    //         {"orderable": false, "aTargets": [0, 3, 6]}// 制定列不参与排序
    //     ]
    // });


    /*分类-添加*/
    function category_add(title, url) {
        var index = layer.open({
            type: 2,
            title: title,
            area: ['600px', '450px'],
            content: url
        });
    }


    //查看子分类
    function category_child(title, url) {
        var index = layer.open({
            type: 2,
            title: title,
            content: url,
            area:['800px', '600px']
        });
        // layer.full(index);
    }


    /*分类-编辑*/
    function category_edit(title, url, id) {
        var index = layer.open({
            type: 2,
            title: title,
            content: url,
            area: ['600px', '450px']
        });
        // layer.full(index);
    }

    /*分类-删除*/
    function category_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            $.post("{:url('departmentDel')}", {ids:id}, function (res) {
                if(res.code == 1){
                    layer.msg(res.msg);
                    $(obj).parents("tr").remove();
                }else{
                    layer.msg(res.msg);
                }
            });
        });
    }
</script>
</body>
</html>